package com.sky.zzh.setting;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;

import com.sky.zzh.R;
import com.sky.zzh.SHApplication;
import com.sky.zzh.SHContainerActivity;
import com.sky.zzh.home.LoginActivity;
import com.sky.zzh.util.ConfigDefinition;
import com.sky.zzh.util.UserInfoManager;
/**
 * 设定
 * @author skypan
 *
 */
public class SettingFragment extends Fragment {

	private TextView mTvInfo,mTvchangePwd,mTvSetPwd,mTvAgreement,mTvAbout,mTvQuit;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view  = inflater.inflate(R.layout.fragment_setting, container, false);
		return view;
	}

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onViewCreated(view, savedInstanceState);
		mTvInfo = (TextView) view.findViewById(R.id.tv_info);
		mTvchangePwd = (TextView) view.findViewById(R.id.tv_change_pwd);
		mTvSetPwd = (TextView) view.findViewById(R.id.tv_set_pwd);
		mTvAgreement = (TextView) view.findViewById(R.id.tv_agreement);
		mTvAbout = (TextView) view.findViewById(R.id.tv_about);
		mTvQuit = (TextView) view.findViewById(R.id.tv_quit);
		
		setListeners();
	}

	private void setListeners(){
		mTvInfo.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(getActivity(),SHContainerActivity.class);
				intent.putExtra("class", SelfInfoFragment.class.getName());
				startActivity(intent);
			}
		});
		
		mTvchangePwd.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(getActivity(),SHContainerActivity.class);
				intent.putExtra("class", ChangePwdFragment.class.getName());
				startActivity(intent);
			}
		});
		
		mTvSetPwd.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(getActivity(),SHContainerActivity.class);
				intent.putExtra("class", SetPwdLockFragment.class.getName());
				startActivity(intent);
			}
		});
		
		mTvAgreement.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(getActivity(),SHContainerActivity.class);
				intent.putExtra("class", HTMLFragment.class.getName());
				startActivity(intent);
			}
		});
		
		mTvAbout.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(getActivity(),SHContainerActivity.class);
				intent.putExtra("class", AboutFragment.class.getName());
				startActivity(intent);
			}
		});
		
		mTvQuit.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(getActivity(),LoginActivity.class);
				startActivity(intent);
				UserInfoManager.getInstance().setLoginType("");
				UserInfoManager.getInstance().setUserId("");
				UserInfoManager.getInstance().sync(getActivity(), true);
				SHApplication.getInstance().onlyLogin();
				getActivity().finish();
			}
		});
	}
}
